package com.ylfstu.Homework;

import java.util.TreeSet;
@SuppressWarnings({"all"})
public class Homework05 {
    public static void main(String[] args) {
        TreeSet treeSet = new TreeSet();
        //add方法报错，TreeSet()构造器没有传入Comparator接口的匿名内部类
        //所以在底层 类型转换时会报错
//        final int compare(Object k1, Object k2) {
//            return comparator==null ? ((Comparable<? super K>)k1).compareTo((K)k2)
//                    : comparator.compare((K)k1, (K)k2);
//        }
        //((Comparable<? super K>)k1).compareTo((K)k2) 会报错
        treeSet.add(new Person());
        treeSet.add(new Person());
        treeSet.add(new Person());
        treeSet.add(new Person());
        System.out.println(treeSet);
    }
}
class Person implements Comparable{
    @Override
    public int compareTo(Object o) {
        return -2;
    }
}